<template>
	<view class="main">
		<view class="title">欢迎登录</view>
		<input class="input" type="number" :class="[focus]" v-model="tel" @focus="focus = 'light'" @blur="focus = ''"
			placeholder="请输入手机号" />
		<view class="tips">未注册的手机号验证后将自动创建账号</view>
		<button class="submit" @tap="getSMS" :disabled="tel.length < 11">获取短信验证码</button>
	</view>
</template>

<script>
	import {
		http
	} from '@/lib/js/request';
	import {
		goPage
	} from '@/lib/js/utils';
	export default {
		data() {
			return {
				focus: '',
				tel: ''
			};
		},
		onLoad() {},

		methods: {
			// 获取短信验证码
			async getSMS() {
				await http('/user/sendsms', {
					tel: this.tel
				});
				goPage(`/pages/mine/code?tel=${this.tel}`);
			}
		}
	};
</script>

<style lang="scss" scoped>
	.main {
		font-size: 28rpx;
		margin: 100rpx;

		.title {
			text-align: left;
			font-size: 54rpx;
			font-weight: 500;
			margin-bottom: 120rpx;
		}

		.input {
			text-align: left;
			margin-bottom: 10rpx;
			padding-bottom: 10rpx;
			border-bottom: 1px solid #ccc;
			transition: 0.2s;

			&.light {
				border-bottom: 1px solid #007aff;
			}
		}

		.tips {
			color: #ccc;
			margin-bottom: 100rpx;
			margin-top: 8rpx;
		}

		.submit {
			background-color: $color-1;
			border: none;
			font-size: 30rpx;
			padding: 12rpx 0;
		}
	}
</style>
